package cn.dglydrpy.study.common.exception;

/**
 * 装饰器业务异常类实现   统一异常处理
 */
public class BusinessException extends Exception implements ICommonError{

    private ICommonError commonError;

    //构造业务异常
    public BusinessException(ICommonError commonError){
        super();
        this.commonError = commonError;
    }
    //自定义errMsg构造业务异常
    public BusinessException(ICommonError commonError,String errMsg){
        super();
        this.commonError = commonError;
        this.commonError.setErrMsg(errMsg);
    }

    @Override
    public int getErrCode() {
        return this.commonError.getErrCode();
    }

    @Override
    public String getErrMsg() {
        return this.commonError.getErrMsg();
    }

    @Override
    public ICommonError setErrMsg(String errMsg) {
        return this.commonError.setErrMsg(errMsg);
    }
}
